/*    */ package com.cr.common.xss;
/*    */ 
/*    */ import com.cr.common.utils.MyStringUtils;
/*    */ import java.io.IOException;
/*    */ import java.util.ArrayList;
/*    */ import java.util.List;
/*    */ import javax.servlet.Filter;
/*    */ import javax.servlet.FilterChain;
/*    */ import javax.servlet.FilterConfig;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.ServletRequest;
/*    */ import javax.servlet.ServletResponse;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ 
/*    */ public class XssFilter implements Filter {
/* 26 */   public List<String> excludes = new ArrayList<>();
/*    */   
/*    */   public void init(FilterConfig filterConfig) throws ServletException {
/* 31 */     String tempExcludes = filterConfig.getInitParameter("excludes");
/* 32 */     if (MyStringUtils.isNotEmpty(tempExcludes)) {
/* 34 */       String[] url = tempExcludes.split(",");
/* 35 */       for (int i = 0; url != null && i < url.length; i++)
/* 37 */         this.excludes.add(url[i]); 
/*    */     } 
/*    */   }
/*    */   
/*    */   public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
/* 46 */     HttpServletRequest req = (HttpServletRequest)request;
/* 47 */     HttpServletResponse resp = (HttpServletResponse)response;
/* 48 */     if (handleExcludeURL(req, resp)) {
/* 50 */       chain.doFilter(request, response);
/*    */       return;
/*    */     } 
/* 53 */     XssHttpServletRequestWrapper xssRequest = new XssHttpServletRequestWrapper((HttpServletRequest)request);
/* 54 */     chain.doFilter((ServletRequest)xssRequest, response);
/*    */   }
/*    */   
/*    */   private boolean handleExcludeURL(HttpServletRequest request, HttpServletResponse response) {
/* 59 */     String url = request.getServletPath();
/* 60 */     String method = request.getMethod();
/* 62 */     if (method == null || method.matches("GET") || method.matches("DELETE"))
/* 64 */       return true; 
/* 66 */     return MyStringUtils.matches(url, this.excludes);
/*    */   }
/*    */   
/*    */   public void destroy() {}
/*    */ }


/* Location:              D:\tmp\creditorRights-admin\BOOT-INF\lib\creditorRights-common-4.7.0.jar!\com\cr\common\xss\XssFilter.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */